import { request, BaseResponse } from '@/utils/request';
/**
 * @description 获取其列表
 * @param {Namespace} isMock
 * @param isGetDataDirectly
 * @returns
 */

/**
 * 用户选择
 * 核心企业树
 */
export function getTreEnterprise() {
  return request<BaseResponse<Namespace.unitTree>>(
    {
      url: `/sys/org/gettree?orgType=ORG`,
      method: 'get',
    },
    {
      isMock: false,
      isGetDataDirectly: false,
    },
  );
}

export function getTreeSupplier() {
  return request<BaseResponse<Namespace.unitTree>>(
    {
      url: `/sys/org/gettree?orgType=VENDOR`,
      method: 'get',
    },
    {
      isMock: false,
      isGetDataDirectly: false,
    },
  );
}

export function getTreeGroup() {
  return request<BaseResponse<Array<Namespace.MyGroup>>>(
    {
      url: `/sys/userselectgroup/getuserdata`,
      method: 'get',
    },
    {
      isMock: false,
      isGetDataDirectly: false,
    },
  );
}

/**
 * 用户选择
 * 查找对象
 */
export function getOrgData(query: { orgId: string }) {
  return request<BaseResponse<Array<Namespace.userDataType>>>(
    {
      url: `/sys/user/getorgdata`,
      method: 'get',
      params: query,
    },
    {
      isMock: false,
      isGetDataDirectly: false,
    },
  );
}

/**
 * 用户选择
 * 查找对象
 */
export function getUserGroupData(query: { userGroupId: string }) {
  return request<BaseResponse<Array<Namespace.userDataType>>>(
    {
      url: `/sys/user/getusergroup`,
      method: 'get',
      params: query,
    },
    {
      isMock: false,
      isGetDataDirectly: false,
    },
  );
}

/** 用户组新增 */
export function getGroupSave(query: Namespace.userGroup) {
  return request<BaseResponse>(
    {
      url: '/sys/userselectgroup/save',
      method: 'post',
      data: query,
      headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    },
    {
      isMock: false,
      isGetDataDirectly: false,
      successMsg: '新增成功',
    },
  );
}

/** 用户组删除 */
export function getGroupRemove(query: { id: string }) {
  return request<BaseResponse>(
    {
      url: '/sys/userselectgroup/remove',
      method: 'post',
      data: query,
      headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    },
    {
      isMock: false,
      isGetDataDirectly: false,
      successMsg: '删除成功',
    },
  );
}
